package test;

import java.util.Scanner;

public class Main {

    public static char[] str;

    // l,r 为反转左右端
    public static void reve(int l, int r) {
        for (int i = l; i < r / 2; i++) {
            //异或交换也可
            char temp;
            temp = str[i];
            str[i] = str[r - i - 1];
            str[r - i - 1] = temp;
        }
    }

    public static void main(String[] args) {
        str = new Scanner(System.in).nextLine().toCharArray();
        //先全串反转
        reve(0, str.length);
        for (int i = 0, k = 0; i < str.length; i++) {
            //遇到空格再单词反转
            if (str[i] == ' ') {
                reve(k, i + k);
                k = i + 1;
            }
            //串尾特殊判断
            if (i == str.length - 1) {
                reve(k, i + k + 1);
            }
        }
        System.out.println(str);
    }
}



